package com.example.homework4;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button mBtnToRegisterAty;
    private Button mBtnToLifeCycleAty;

    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();

        initListener();


    }

    private void initListener() {
        mBtnToLifeCycleAty.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //去测试Activity生命周期
                Intent intent = new Intent(MainActivity.this, LifeCycleActivity.class);
                startActivity(intent);
                Log.d(TAG, "onClick: 测试Activity生命周期");
            }
        });

        mBtnToRegisterAty.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //去注册页面
                Intent intent = new Intent(MainActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });
    }

    private void initView() {
        mBtnToLifeCycleAty = findViewById(R.id.btn_toLifecycleAty);
        mBtnToRegisterAty = findViewById(R.id.btn_toRegisterAty);
    }
}